package com.siwei.mes.entity;

import cn.dev33.satoken.stp.StpUtil;
import com.siwei.mes.common.validator.AddGroup;
import com.siwei.mes.common.validator.UpdateGroup;
import com.siwei.mes.config.UidUtils;
import com.siwei.mes.enums.GenerateCodeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;


/**
 * 快检指标配置(CheckQuickConfig)实体类
 *
 * @author linzi
 * @since 2023-11-25 22:22:19
 */
@Data
@Accessors(chain = true)
@Table(name = "t_check_quick_config")
@ApiModel(value = "CheckQuickConfig", description = "快检指标配置")
public class CheckQuickConfig implements Serializable {
    private static final long serialVersionUID = -44049695091435536L;
    /**
     * 快检主键id
     */
    @Id
    @ApiModelProperty(value = "快检指标配置主键ID", name = "id")
    @NotNull(groups = {UpdateGroup.class}, message = "快检指标主键id为空")
    private Long id;
    /**
     * 快检code
     */
    @Column(name = "quick_code")
    @ApiModelProperty(value = "快检code", name = "quickCode")
    private String quickCode;
    /**
     * 产品名称
     */
    @Column(name = "project_name")
    @ApiModelProperty(value = "产品名称", name = "projectName")
    private String projectName;
    /**
     * 产品名称code
     */
    @Column(name = "project_name_code")
    @ApiModelProperty(value = "产品名称code", name = "projectNameCode")
    private String projectNameCode;
    /**
     * 产品规格
     */
    @Column(name = "project_specs")
    @ApiModelProperty(value = "产品规格", name = "projectSpecs")
    private String projectSpecs;
    /**
     * 产品规格code
     */
    @Column(name = "project_specs_code")
    @ApiModelProperty(value = "产品规格code", name = "projectSpecsCode")
    private String projectSpecsCode;
    /**
     * 产品类型 对应字典表  MASTERIAL_TYPE
     */
    @Column(name = "project_category")
    @ApiModelProperty(value = "产品类型 对应字典表  MASTERIAL_TYPE", name = "projectCategory")
    @NotNull(groups = {AddGroup.class, UpdateGroup.class}, message = "产品类型为空")
    private Integer projectCategory;
    /**
     * 国标值
     */
    @Column(name = "national_standard_value")
    @ApiModelProperty(value = "国标值", name = "nationalStandardValue")
    private String nationalStandardValue;
    /**
     * 试验项目code  试验项目表   多个用逗号隔开
     */
    @Column(name = "test_project_code")
    @ApiModelProperty(value = "试验项目code  试验项目表 多个用逗号隔开", name = "testProjectCode")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "试验项目code为空")
    private String testProjectCode;
    /**
     * 试验项目名称  多个用逗号隔开
     */
    @Column(name = "test_project_name")
    @ApiModelProperty(value = "试验项目名称", name = "testProjectName")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "试验项目名称为空")
    private String testProjectName;

    @Column(name = "check_value_unit")
    @ApiModelProperty(value = "检测值单位")
    private String checkValueUnit;

    /**
     * 合格指标1类型 1-大于 2-大于等于  3-等于 4-不等于 5-小于  6-小于等于
     */
    @Column(name = "qualified_check_one_type")
    @ApiModelProperty(value = "合格指标1类型 1-大于 2-大于等于  3-等于 4-不等于 5-小于  6-小于等于", name = "qualifiedCheckOneType")
    private Integer qualifiedCheckOneType;
    /**
     * 合格指标1 值
     */
    @Column(name = "qualified_check_one_value")
    @ApiModelProperty(value = "合格指标1 值", name = "qualifiedCheckOneValue")
    private Long qualifiedCheckOneValue;
    /**
     * 合格指标2类型 1-大于 2-大于等于  3-等于 4-不等于 5-小于  6-小于等于
     */
    @Column(name = "qualified_check_two_type")
    @ApiModelProperty(value = "合格指标2类型 1-大于 2-大于等于  3-等于 4-不等于 5-小于  6-小于等于", name = "qualifiedCheckTwoType")
    private Integer qualifiedCheckTwoType;
    /**
     * 合格指标2 值
     */
    @Column(name = "qualified_check_two_value")
    @ApiModelProperty(value = "合格指标2 值", name = "qualifiedCheckTwoValue")
    private Long qualifiedCheckTwoValue;
    /**
     * 合格指标text
     */
    @Column(name = "qualified_check_text")
    @ApiModelProperty(value = "合格指标text", name = "qualifiedCheckText")
    private String qualifiedCheckText;
    /**
     * 让步指标1类型 1-大于 2-大于等于  3-等于 4-不等于 5-小于  6-小于等于
     */
    @Column(name = "compromise_check_one_type")
    @ApiModelProperty(value = "让步指标1类型 1-大于 2-大于等于  3-等于 4-不等于 5-小于  6-小于等于", name = "compromiseCheckOneType")
    private Integer compromiseCheckOneType;
    /**
     * 让步指标1 值
     */
    @Column(name = "compromise_check_one_value")
    @ApiModelProperty(value = "让步指标1 值", name = "compromiseCheckOneValue")
    private Long compromiseCheckOneValue;
    /**
     * 让步指标2类型 1-大于 2-大于等于  3-等于 4-不等于 5-小于  6-小于等于
     */
    @Column(name = "compromise_check_two_type")
    @ApiModelProperty(value = "让步指标2类型 1-大于 2-大于等于  3-等于 4-不等于 5-小于  6-小于等于", name = "compromiseCheckTwoType")
    private Integer compromiseCheckTwoType;
    /**
     * 让步指标2 值
     */
    @Column(name = "compromise_check_two_value")
    @ApiModelProperty(value = "让步指标2 值", name = "compromiseCheckTwoValue")
    private Long compromiseCheckTwoValue;
    /**
     * 让步指标text
     */
    @Column(name = "compromise_check_text")
    @ApiModelProperty(value = "让步指标text", name = "compromiseCheckText")
    private String compromiseCheckText;
    /**
     * 扣除规则  每百分之多少
     */
    @Column(name = "deduction_threshold")
    @ApiModelProperty(value = "扣除规则  每百分之多少", name = "deductionThreshold")
    // @NotNull(groups = {AddGroup.class, UpdateGroup.class}, message = "扣除规格 每百分之多少为空")
    private Double deductionThreshold;
    /**
     * 扣除规则 扣除百分之多少
     */
    @Column(name = "deduction_percentage")
    @ApiModelProperty(value = "扣除规则 扣除百分之多少", name = "deductionPercentage")
    // @NotNull(groups = {AddGroup.class, UpdateGroup.class}, message = "扣除规格 扣除百分之多少为空")
    private Double deductionPercentage;

    /**
     * 快检规则 1-小票数量  2-小票方量  3-车车都检
     */
    @Column(name = "quick_rules")
    @ApiModelProperty(value = "快检规则 1-小票数量  2-小票方量  3-车车都检", name = "batchRules")
    @NotNull(groups = {AddGroup.class, UpdateGroup.class}, message = "批检规格为空")
    private Long quickRules;
    /**
     * 快检阈值
     */
    @Column(name = "quick_threshold")
    @ApiModelProperty(value = "快检阈值", name = "batchThreshold")
    private Double quickThreshold;

    /**
     * 上传检验图片 1-是 0-否
     */
    @Column(name = "is_upload_img")
    @ApiModelProperty(value = "上传检验图片 1-是 0-否", name = "isUploadImg")
    @NotNull(groups = {AddGroup.class, UpdateGroup.class}, message = "是否上传检验图片为空")
    private Integer isUploadImg;
    /**
     * 是否必检  1-是 0-不是
     */
    @Column(name = "is_must")
    @ApiModelProperty(value = "是否必检  1-是 0-不是", name = "isMust")
    @NotNull(groups = {AddGroup.class, UpdateGroup.class}, message = "是否必检为空")
    private Integer isMust;
    /**
     * 备注
     */
    @Column(name = "remark")
    @ApiModelProperty(value = "备注", name = "remark")
    private String remark;
    /**
     * 创建人
     */
    @Column(name = "creater")
    @ApiModelProperty(value = "创建人", name = "creater")
    private Long creater;
    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间", name = "createTime")
    private Date createTime;
    /**
     * 修改人
     */
    @Column(name = "updater")
    @ApiModelProperty(value = "修改人", name = "updater")
    private Long updater;
    /**
     * 更新时间
     */
    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间", name = "updateTime")
    private Date updateTime;
    /**
     * 是否删除  0-未删除  1-删除
     */
    @Column(name = "is_del")
    @ApiModelProperty(value = "是否删除  0-未删除  1-删除", name = "isDel")
    private Integer isDel;

    public CheckQuickConfig init(boolean isCreate) {
        this.setUpdater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null).setUpdateTime(new Date());
        if (isCreate) {
            this.setCreater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null).setCreateTime(new Date()).setIsDel(0)
                    .setQuickCode(UidUtils.genNo(GenerateCodeEnum.CHECK_QUICK.getCode()));
        }
        return this;
    }
}
